{% extends "base.html" %}

{% block purchase %} class="active" {% endblock %}

{% block content %}
<div class="panel panel-primary">
    <div class="panel-heading">查询条件</div>
    <div class="panel-body">
    <form method="post" class="form-inline" action="/purchasequery">
        {{ form.hidden_tag() }}
        <div class="form-group">
            {{ form.sdate.label}} {{ form.sdate(class='form-control') }}
        </div>
        <div class="form-group">
            {{ form.edate.label}} {{ form.edate(class='form-control') }}
        </div>
        <div class="form-group">
            {{ form.pgoods.label}} {{ form.pgoods(class='form-control') }}
        </div>
        <div class="form-group">
            {{ form.psupplier.label}} {{ form.psupplier(class='form-control') }}
        </div>
        <div class="form-group">
            {{ form.pok(class='btn btn-primary') }}
        </div>
    </form>
    </div>
</div>
<div class="panel panel-primary">
    <div class="panel-heading">
        <a class="btn btn-info" href="/purchaseadd" role="button">新增采购订单</a>
    </div>
     <div class="panel-body">
    <div class="table-responsive">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>序号</th>
                    <th>编号</th>
                    <th>日期</th>
                    <th>商品名称</th>
                    <th>商品品牌</th>
                    <th>商品型号</th>
                    <th>单价</th>
                    <th>数量</th>
                    <th>计量单位</th>
                    <th>总金额</th>
                    <th>供应商</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {% for item in tabinfo %}
                <tr>
                    <td>{{ item[1] }}</td>
                    <td>{{ item[2] }}</td>
                    <td>{{ item[3] }}</td>
                    <td>{{ item[4] }}</td>
                    <td>{{ item[5] }}</td>
                    <td>{{ item[6] }}</td>
                    <td>￥ {{ item[7] }}</td>
                    <td>{{ item[8] }}</td>
                    <td>{{ item[9] }}</td>
                    <td>￥ {{ item[10] }}</td>
                    <td>{{ item[11] }}</td>
                    <td>
                        <a class="btn btn-info btn-xs" href="/purchasedel?delid={{ item[12] }}" role="button">删除</a>
                        <a class="btn btn-info btn-xs" href="/purchaseupdate?upid={{ item[12] }}" role="button">修改</a>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
  </div>
  <div class="container-fluid">
      <nav aria-label="Page navigation">
          <ul class="pagination pagination-lg">
              <li>
                  {% if page[1] is equalto(1) %}
                      <a href="#" aria-label="Previous" class="disabled">
                  {% else %}
                      <a href="?page={{ page[1]-1 }}&goods={{ query_info[0] }}&supplier={{ query_info[1] }}&sdate={{ query_info[2] }}&edate={{ query_info[3] }}" aria-label="Previous" >
                  {% endif %}
                      <span aria-hidden="true">&laquo;</span>
                  </a>
              </li>
              {% for i in range(1,page[0]) %}
                {% if loop.index is equalto(page[1]) %}
                    <li class="active"><a href="?page={{ loop.index }}&goods={{ query_info[0] }}&supplier={{ query_info[1] }}&sdate={{ query_info[2] }}&edate={{ query_info[3] }}">{{ loop.index }}</a></li>
                {% else %}
                    <li ><a href="?page={{ loop.index }}&goods={{ query_info[0] }}&supplier={{ query_info[1] }}&sdate={{ query_info[2] }}&edate={{ query_info[3] }}">{{ loop.index }}</a></li>
                {% endif %}
              {% endfor %}
              <li>
                  {% if page[1] is equalto(page[0]-1) %}
                      <a href="#" aria-label="Next" class="disabled">
                  {% else %}
                      <a href="?page={{ page[1]+1 }}&goods={{ query_info[0] }}&supplier={{ query_info[1] }}&sdate={{ query_info[2] }}&edate={{ query_info[3] }}" aria-label="Next" >
                  {% endif %}
                      <span aria-hidden="true">&raquo;</span>
                  </a>
              </li>
          </ul>
      </nav>
  </div>
     </div>
</div>
{% endblock%}
